package com.itheima.executors;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorsDemo01 {
    public static void main(String[] args) {
        //创建池子
        ExecutorService executorService = Executors.newCachedThreadPool();

        //将任务给线程池
        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"线程运行了");
        });

        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName()+"线程运行了");
        });

        //关闭池
        executorService.shutdown();

        //输出：
//        pool-1-thread-2线程运行了
//        pool-1-thread-1线程运行了

    }
}
